package com.tvunetworks.center.user.mapper;

import com.tvunetworks.center.user.model.RoleDevice;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Set;

/**
 * @author Etan Yang
 * @data: 2021/4/7 15:22
 * @program: tvucc-aggregator
 * @description:
 */

public interface RoleDeviceMapper extends Mapper<RoleDevice> {

    /**
     * 批量插入数据
     * @param roleId roleId
     * @param peerIds peerIds
     * @return int
     */
    int batchInsert(@Param("roleId") String roleId, @Param("peerIds") Set<String> peerIds);

    /**
     * 根据roleId和peerId的集合删除RoleDevice
     * @param roleId roleId
     * @param peerIds peerIds
     */
    void batchDeleteByRoleIdAndPeerIds(@Param("roleId") String roleId,@Param("peerIds") List<String> peerIds);

    /**
     * 根据roleId删除RoleDevice
     * @param roleId roleId
     * @return int
     */
    int deleteByRoleId(@Param("roleId") String roleId);

    /**
     * 根据roleId获取所有的PeerId
     * @param roleId roleId
     * @return List
     */
    List<String> getPeerIdsByRoleId(@Param("roleId")String roleId);

    /**
     * 根据userid 获取用户下在role_mange中设置过的设备
     * @param userId userId
     * @return peerid集合
     */
    List<String> getDeviceListByUser(@Param("userId")String userId);

    /**
     * 根据roleId和peerIds获取roleDevice的集合
     * @param roleId roleId
     * @param peerIds peeerIds
     * @return 返回对应的roleDevice集合
     */
    List<RoleDevice> listRoleDeviceByRoleIdAndPeerIds(@Param("roleId") String roleId, @Param("peerIds") List<String> peerIds);

    /**
     * 根据主键id批量删除
     * @param ids roleDevice的主键id集合
     */
    void batchDeleteByIds(@Param("ids") List<String> ids);
}
